Apache HTTP Server Version 1.3

Apache DSSI 1.0.0

(SSI extention for calling Dynamic function)


Summary

By using this extentions to mod_include, you can make your own function for SSI (Server Side Includes) and you can call your function with SSI directives. This solution is based on mod_so and mod_include. By using DSSI, you can integrate your CGI easily and make your CGI faster than any other CGI accelerator.


How to Install

  1. Download and compile Apache 1.3.X
  2. Simply download dssi_1.0.0.tar.gz
  3. Unzip and untar.
  4. Replace apache_1.3.X/src/modules/standard/mod_include.c with this mod_include.c
  5. Configure.
    ./configure --enable-module=include
    If your binary type is ELF,
    LDFLAGS="-export-dynamic" ./configure --enable-module=include
  6. Compile and install apache.

Enabling DSSI

By using LoadDSSI directive, you can load your dynamic functions. Later one override earlier ones. It means, you can only call functions of the last one with DSSI directive.

AddType text/html .shtml
AddHandler server-parsed .shtml
LoadDSSI libexec/dssi_util.so
LoadDSSI libexec/dssi.so


DSSI Directive

<!--#exec func="dssi_function_name dssi_function_arguments"-->
dssi_function_arguments should not contain white spaces.


How to make dssi.so

You can write DSSI funtions by using Apache API functions.

Example

temp_cgi.c:

#include <stdio.h>

void main()
{
  char *s;
  printf("Content-type: text/html\n\n");
  printf("<html><body><pre>\n");
  s = (char *)getenv("QUERY_STRING");
  if(s && *s)
    printf("%s\n",s);
  s = (char *)getenv("DOCUMENT_ROOT");
  if(s && *s)
    printf("%s\n",s);
  printf("</pre></body></html>");
}

You can simply integrate this CGI to DSSI.
  1. Change stdio functions to Apache API functions. (printf --> rprintf)
  2. Change "getenv" function to "ap_table_get".
  3. Write .shtml file.
temp_dssi.c:

#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
#include "util_date.h"

int temp_dssi(request_rec *r, char *args)
{
  const char *s;
  s = ap_table_get(r->subprocess_env,"QUERY_STRING");
  if(s && *s)
    ap_rprintf(r,"%s\n",s);
  if(args && *args)
    ap_rprintf(r,"%s\n",args);
  return OK;
}


Compiling:

$ gcc -c -I/apache_root_dir/include -O2 temp_dssi.c
$ gcc -I/apache_root_dir/include -O2 temp_dssi.o -shared -o temp_dssi.so
$ cp temp_dssi.so /apache_root_dir/libexec/


httpd.conf:

LoadDSSI libexec/temp_dssi.so


temp_dssi.shtml:

<html><body><pre>
<!--#exec func="temp_dssi $DOCUMENT_ROOT" -->
</pre></body></html>


Extra Functions

POST

DSSI extention allow you to handle POST method.

NPH (non-parsed headers)

You can use the "nph-" prefix for the file name. It's a litte bit different from "nph-" CGIs. It's just disabling "ap_send_http_header(r)".


OS Platform

DSSI is just tested in the UNIX Platform. If you are using the others, let me know the problem.


Contacts and Sponsoring


S.J.G